#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtWidgets>
#include <QtSql>

class GraphicsItem;
class ItemInfoWindow;

namespace Ui {
class MainWindow;
}

class MainWindow : public QGraphicsView
{
    Q_OBJECT

public:
    explicit MainWindow(const QString &items, const QString &images,QWidget *parent = nullptr);
    ~MainWindow();
protected:
    void mouseReleaseEvent(QMouseEvent *event) override;

private:
    void addItems();
    void showInformation(GraphicsItem *image);
    ItemInfoWindow *findWindow(int id) const;
    void updateImage(int id, const QString &fileName);
private:
    QGraphicsScene *scene;
    QList<ItemInfoWindow *> informationWindows;
    QSqlRelationalTableModel *itemTable;
};

#endif // MAINWINDOW_H
